home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / PersonalPreferences / PersonalPreferences.m < prev    next >
Text File  |  1995-06-12  |  3KB  |  144 lines

  1. //
  2. //    A loadable Preference Bundle example.
  3. //    Greg Burd
  4. //        Copyright NeXT Computer, Inc 1992 All Rights Reserved
  5. //
  6. //    Created 8-24-92
  7. //
  8. //    You may freely copy, distribute and reuse the code in this example.
  9. //    NeXT disclaims any warranty of any kind, expressed or implied, as to
  10. //    its fitness for any particular use.
  11. //
  12.  
  13. #import <appkit/appkit.h>
  14.  
  15. #import "PersonalPreferences.h"
  16. #import "Text_Console.h"
  17.  
  18. @implementation PersonalPreferences
  19.  
  20. + new
  21. /*
  22.     Called first time this section's button is clicked.
  23. */
  24. {
  25.     self = [super new];
  26.     
  27.     if( ![NXApp loadNibForLayout:"PersonalPreferences" owner: self] )
  28.     return 0;
  29.     
  30.     // 'window' is an interface builder outlet.
  31.     view = [window contentView];    // 'view' MUST be initialized
  32.     [view removeFromSuperview];
  33.     [window setContentView: 0];        // Don't need the window for anything
  34.     [window free];                    // So free it.
  35.     
  36.     // Do any other set up here.
  37.     
  38.     return self;
  39. }
  40.  
  41. - willSelect: sender
  42. /*
  43.     Before the view is added via addSubview
  44. */
  45. {
  46.     [text printf:"In - willSelect:\n"];
  47.     return self;
  48. }
  49.  
  50. - didSelect: sender
  51. /*
  52.     After the view is added via addSubview
  53. */
  54. {
  55.     /*
  56.     Enable all of the edit and window menu items, just for the heck of it.
  57.     */
  58.     [text printf:"In - didSelect:\n"];
  59.     
  60.     // These just allow you to restrict actions that the use might
  61.     //  want to do.
  62.     [NXApp enableEdit: CUT_ITEM|COPY_ITEM|PASTE_ITEM|SELECTALL_ITEM];
  63.     [NXApp enableWindow: MINIATURIZE_ITEM|CLOSE_ITEM];
  64.     return self;
  65. }
  66.  
  67.  
  68. - willUnselect: sender
  69. /*
  70.     Before removeFromSuperview
  71. */
  72. {
  73.     /* Make sure that we aren't editing any text fields. For instance if
  74.         you were doing something like the password preference, you would
  75.         not send the endEditingFor: if the user had not completed the
  76.         process of creating a new password.
  77.     */
  78.     [text printf:"In - willUnselect:\n"];
  79.     [[NXApp appWindow] endEditingFor: self];  
  80.     return self;
  81. }
  82.  
  83. - didUnselect: sender
  84. /*
  85.     Before removeFromSuperview
  86. */
  87. {
  88.     /*
  89.     Disable all of the edit and window menu items, just for the heck of it.
  90.     */
  91.     [text printf:"In - didUnselect:\n"];
  92.     [NXApp enableEdit: NO];
  93.     [NXApp enableWindow: NO];
  94.     return self;
  95. }
  96.  
  97. - didHide: sender
  98. /*
  99.     Application was just hidden.
  100. */
  101. {
  102.     [text printf:"In - didHide:\n"];
  103.     // in here you should be nice and free all the memory you can, you don't
  104.     // want to waste memory just sitting there while the clock ticks away...
  105.     return self;
  106. }
  107.  
  108. - didUnhide: sender
  109. /*
  110.     Application was just unhidden.
  111. */
  112. {
  113.     [text printf:"In - didUnhide:\n"];
  114.     // time to reconstruct that memory that you freed earlier.  :-)
  115.     return self;
  116. }
  117.  
  118. - button1Clicked: sender
  119. {
  120.     [text printf:"In - button1Clicked:\n"];
  121.     return self;
  122. }
  123.  
  124. - button2Clicked: sender
  125. {
  126.     [text printf:"In - button2Clicked:\n"];
  127.     return self;
  128. }
  129.  
  130. - gotText:sender
  131. {
  132.     [text printf:"In - gotText:(%s)\n",[sender stringValue]];
  133.     return self;
  134. }
  135.  
  136. - free
  137. {
  138.     [text printf:"In - free\n"];
  139.     // don't forget to be nice and free everything that you malloc'ed!
  140.     return [super free];
  141. }
  142. @end
  143.  
  144.